import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { MarryProcessCell } from "./cellRenderer/MarryProcessCell";
import { Language } from "../../../../extend/language/Language";
import { WindowEvent } from "../../../component/window/WindowEvent";
import { ObjCreate } from "../common/ObjCreate";
import { PublicMessageConfig } from "../../resource/PublicMessageConfig";
import { EventName } from "../../mvc/EventName";
import { ProcessCellType } from "./defin/ProcessCellType";
import { Cache } from "../../cache/Cache";
import { DataEvent } from "../../events/DataEvent";
import { Vector } from "../../../../__AS3__/vec/Vector";
//class MarryProcess
    
    export  class MarryProcess extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._vcProcessCell = new Vector.<MarryProcessCell>();
            setSize(410, 446);
            title = Language.getString(43625);
            titleHeight = 26;
            this.addEventListener(WindowEvent.SHOW, this.onShow);
            return;
        }

        /* internal  */onShow(arg1: WindowEvent): void
        {
            this.updateState();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 39, 374, 394, this);
            this.updateView();
            return;
        }

        /* internal  */updateView(): void
        {
            var loc2=0;
            var loc3=null;
            var loc1=52;
            loc2 = 1;
            while (loc2 <= 5) 
            {
                loc3 = new MarryProcessCell();
                loc3.updateData("MarryProcess" + loc2 + ".png", PublicMessageConfig.instance.getMarryDescByName("marryProcessDes" + loc2));
                loc3.x = 30;
                loc3.y = loc1;
                this._vcProcessCell.push(loc3);
                this.addChild(loc3);
                if (loc2 != 1) 
                {
                    loc3.hideDes();
                }
                else 
                {
                    loc3.showDes();
                    this._currentMarryProcessCell = loc3;
                }
                loc1 = loc1 + loc3.height;
                loc3.addEventListener(EventName.MarryShowProcess, this.onShowProcess);
                ++loc2;
            }
            return;
        }

        public updateState(): void
        {
            this._vcProcessCell[0].updateState(ProcessCellType.Register, Cache.instance.marry.weddingStatus);
            this._vcProcessCell[1].updateState(ProcessCellType.Book, Cache.instance.marry.weddingStatus);
            this._vcProcessCell[2].updateState(ProcessCellType.Inivte, Cache.instance.marry.weddingStatus);
            this._vcProcessCell[3].updateState(ProcessCellType.Parade, Cache.instance.marry.weddingStatus);
            this._vcProcessCell[4].updateState(ProcessCellType.Wedding, Cache.instance.marry.weddingStatus);
            return;
        }

        /* internal  */onShowProcess(arg1: DataEvent): void
        {
            var loc3=0;
            var loc1=arg1.target as MarryProcessCell;
            if (this._currentMarryProcessCell) 
            {
                this._currentMarryProcessCell.hideDes();
            }
            this._currentMarryProcessCell = loc1;
            var loc2=52;
            loc3 = 0;
            while (loc3 < this._vcProcessCell.length) 
            {
                this._vcProcessCell[loc3].x = 30;
                this._vcProcessCell[loc3].y = loc2;
                loc2 = loc2 + this._vcProcessCell[loc3].height;
                ++loc3;
            }
            return;
        }

        /* internal */ /* var */_currentMarryProcessCell: MarryProcessCell;

        /* internal */ /* var */_vcProcessCell: Vector.<MarryProcessCell>;
    }
